import { Rect } from "./Rect";

export class Collisione2dUtil {

    /**
     * 轴对称包围盒（Axis-Aligned Bounding Box
     * 判断任意两个（无旋转）矩形的任意一边是否无间距，从而判断是否碰撞
     * @param r1 
     * @param r2 
     */
    public static aabbCollision(r1: Rect, r2: Rect): boolean {
        let bool = r1.x < r2.x + r2.width
            && r1.x + r1.width > r2.x
            && r1.y < r2.y + r2.height
            && r1.y + r1.height > r2.y;
        return bool;
    }
}